package com.sghd.fight.module.game.core.model;

import com.sghd.pojo.fight.game.BattleSkillVo;

/**
 * @author frank
 * @date 2018-10-23 14:24
 * @desc 玩家上阵的技能
 **/
public class BattleSkill {
    /** 技能id*/
    private int skillId;
    /** 总共需要的冷确回合*/
    private int cool;
    /** 当前冷确回合*/
    private int current;
    private int level;
    public BattleSkill() {
    }

    public BattleSkill(int skillId, int cool, int level) {
        this.skillId = skillId;
        this.cool = cool;
        this.current = cool;
        this.level = level;
    }

    public BattleSkill(int skillId) {
        this.skillId = skillId;
    }

    public int getSkillId() {
        return skillId;
    }

    public void setSkillId(int skillId) {
        this.skillId = skillId;
    }

    public int getCool() {
        return cool;
    }

    public void setCool(int cool) {
        this.cool = cool;
    }

    public boolean canUse() {
        boolean can = cool == current;
        if (can) {
            use();
        }
        return can;
    }

    public boolean isCanUse() {
        boolean can = cool == current;
        return can;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    /** 冷确回复*/
    public void cool() {
        if (current < cool) {
            current++;
        }
    }

    /** 使用后技能进入冷确*/
    public void use() {
        current = 1;
    }

    public BattleSkillVo toVo() {
        return BattleSkillVo.valueOf(skillId, (cool - current), level);
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }
}
